import fn from vim

string.uindex = (index) => fn.strcharpart(self, index - 1, 1)
string.uslice = (start, len) => fn.strcharpart(self, start - 1, len)
string.ulen = => fn.strchars(self)

current_line = ->
  fn.getline'.'

before_cursor = ->
  line = vim.fn.getline'.'
  col = vim.fn.col'.'
  fn.strpart(line, 0, col - 1)

after_cursor = ->
  line = vim.fn.getline'.'
  col = vim.fn.col'.'
  fn.strpart(line, col - 1)

{ :current_line, :before_cursor, :after_cursor }
